//package com.zzyl.nursing.controller;
//
//import java.util.List;
//import javax.servlet.http.HttpServletResponse;
//
//import com.zzyl.nursing.dto.CheckInApplyDto;
//import com.zzyl.nursing.vo.CheckInDetailVo;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.PutMapping;
//import org.springframework.web.bind.annotation.DeleteMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import com.zzyl.common.annotation.Log;
//import com.zzyl.common.core.controller.BaseController;
//import com.zzyl.common.core.domain.AjaxResult;
//import com.zzyl.common.enums.BusinessType;
//import com.zzyl.nursing.domain.CheckIn;
//import com.zzyl.nursing.service.ICheckInService;
//import com.zzyl.common.utils.poi.ExcelUtil;
//import com.zzyl.common.core.page.TableDataInfo;
//
///**
// * 入住Controller
// *
// * @author zxw
// * @date 2025-10-10
// */
//@RestController
//@RequestMapping("/nursing/checkIn")
//@Api(tags = "入住的接口")
//public class CheckInController extends BaseController {
//    @Autowired
//    private ICheckInService checkInService;
//
//    /**
//     * 查询入住列表
//     */
//    @ApiOperation("查询入住列表")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(CheckIn checkIn) {
//        startPage();
//        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出入住列表
//     */
//    @ApiOperation("导出入住列表")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:export')")
//    @Log(title = "入住", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, CheckIn checkIn) {
//        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
//        ExcelUtil<CheckIn> util = new ExcelUtil<CheckIn>(CheckIn.class);
//        util.exportExcel(response, list, "入住数据");
//    }
//
//    /**
//     * 获取入住详细信息
//     */
//    @ApiOperation("获取入住详细信息")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@ApiParam(value = "入住ID", required = true)
//                              @PathVariable("id") Long id) {
//        return success(checkInService.selectCheckInById(id));
//    }
//
//    /**
//     * 新增入住
//     */
//    @ApiOperation("新增入住")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:add')")
//    @Log(title = "入住", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@ApiParam(value = "入住实体")
//                          @RequestBody CheckIn checkIn) {
//        return toAjax(checkInService.insertCheckIn(checkIn));
//    }
//
//    /**
//     * 修改入住
//     */
//
//    @ApiOperation("修改入住")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:edit')")
//    @Log(title = "入住", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@ApiParam(value = "入住实体")
//                           @RequestBody CheckIn checkIn) {
//        return toAjax(checkInService.updateCheckIn(checkIn));
//    }
//
//    /**
//     * 删除入住
//     */
//
//    @ApiOperation("删除入住")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:remove')")
//    @Log(title = "入住", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids) {
//        return toAjax(checkInService.deleteCheckInByIds(ids));
//    }
//
//    /**
//     * 申请入住
//     */
//    @PostMapping("/apply")
//    public AjaxResult apply(@RequestBody CheckInApplyDto applyDto) {
//        checkInService.apply(applyDto);
//        return AjaxResult.success();
//
//    }
//
//    /**
//     * 查询入住详情
//     */
//    @ApiOperation("查询入住详情")
//    @PreAuthorize("@ss.hasPermi('nursing:checkIn:list')")
//    @GetMapping("/detail/{id}")
//    public AjaxResult getDetail(@PathVariable("id") Long id) {
//
//        CheckInDetailVo checkInDetailVo = checkInService.selectDetail(id);
//        return AjaxResult.success(checkInDetailVo);
//
//    }
//}
package com.zzyl.nursing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zzyl.nursing.dto.CheckInApplyDto;
import com.zzyl.nursing.vo.CheckInDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.CheckIn;
import com.zzyl.nursing.service.ICheckInService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 入住管理Controller
 *
 * @author yjb
 * @date 2025-10-10
 */
@RestController
@RequestMapping("/nursing/checkIn")
@Api(tags = "入住管理的接口")
public class CheckInController extends BaseController {
    @Autowired
    private ICheckInService checkInService;

    /**
     * 查询入住管理列表
     */
    @ApiOperation("查询入住管理列表")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckIn checkIn)
    {
        startPage();
        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
        return getDataTable(list);
    }

    /**
     * 导出入住管理列表
     */
    @ApiOperation("导出入住管理列表")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:export')")
    @Log(title = "入住管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckIn checkIn)
    {
        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
        ExcelUtil<CheckIn> util = new ExcelUtil<CheckIn>(CheckIn.class);
        util.exportExcel(response, list, "入住管理数据");
    }

    /**
     * 获取入住管理详细信息
     */
    @ApiOperation("获取入住管理详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam(value = "入住管理ID", required = true)
                              @PathVariable("id") Long id)
    {
        return success(checkInService.selectCheckInById(id));
    }

    /*
     * 查询入住详情*/
    @ApiOperation("查询入住详情")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:query')")
    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@ApiParam(value = "入住管理ID", required = true)
                             @PathVariable("id") Long id)
    {
        CheckInDetailVo checkInDetailVo = checkInService.detail(id);
        return success(checkInDetailVo);
    }

    /**
     * 新增入住管理
     */
    @ApiOperation("新增入住管理")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:add')")
    @Log(title = "入住管理", businessType = BusinessType.INSERT)
    @PostMapping("/apply")
    public AjaxResult apply(@ApiParam(value = "入住管理实体")
                            @RequestBody CheckInApplyDto dto)
    {
        return toAjax(checkInService.apply(dto));
    }

    /**
     * 修改入住管理
     */
    @ApiOperation("修改入住管理")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:edit')")
    @Log(title = "入住管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam(value = "入住管理实体")
                           @RequestBody CheckIn checkIn)
    {
        return toAjax(checkInService.updateCheckIn(checkIn));
    }

    /**
     * 删除入住管理
     */
    @ApiOperation("删除入住管理")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:remove')")
    @Log(title = "入住管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(checkInService.deleteCheckInByIds(ids));
    }
}
